home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6188 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: ix.netcom.com!netnews
  2. From: Manuel Hernandez <ManuelHe@ix.netcom.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: cin.get(string) problem
  5. Date: 11 Feb 1996 07:55:49 GMT
  6. Organization: Netcom
  7. Message-ID: <4fk7e5$j9h@cloner3.netcom.com>
  8. NNTP-Posting-Host: irv-ca9-20.ix.netcom.com
  9. X-NETCOM-Date: Sat Feb 10 11:55:49 PM PST 1996
  10.  
  11. greinerk@ix.netcom.com (Kurt W. Greiner) writes:
  12. > Hi all,
  13. >         i was trying some really simple io for a program that just gets 
  14. > values, here is a sample of code
  15. > #include <iostream.h>
  16. > void main(void)
  17. > {
  18. >         char string[80];
  19. >         cin.get(string,sizeof(string));
  20. >         cin.get(string,sizeof(string));
  21. > }
  22. > ok, say i want to read in a name on the first cin, i type in "john smith" and 
  23. > the prompt, john gets thrown in to the first and smith the second, i do not 
  24. > even get prompted for the second cin. it does not happen if i type in a string 
  25. > with out spaces. i am using borland c++ 2.0, am i doing something wrong or is 
  26. > there an other way of doing this other than gets(string)?
  27. > kurt
  28. I wish I could help you because I am experiencing the same sort of 
  29. problems. First I  to input into a string with a cin.getline. second I 
  30. input an integer with " cin>> variable ". Next  I try and input a second
  31. string. When I run the code I don't get prompted for the second string. I have
  32. I have been told it has to do with the computer recoginzing the
  33. null terminator, so that is what I will tell you. 
  34.  
  35. What do you get when you step through your code? I could not interpret the 
  36. <iostream.h> very well. I went to buy a book that specialized in iostream programming
  37. but it was forty bucks. I can't afford to spend $40 everytime I hit a snag unless I can't
  38. find the answer elsewhere. I will search the net to see if I can find references to 
  39. cin and recognizing the end of line character. I'll keep you posted
  40.  
  41.